package cn.com.jinhao.provider.business.mapper;


import cn.com.jinhao.hotline.commons.vo.user.OrganizerResponseVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface CommonMapper {
    @Select("SELECT ST$DEPT_CODE_B as originalDeptCode, ST$DEPT_DEPT_B as originalDept FROM ${tableName} WHERE BT$EVIF_CODE = ${eventCode} AND isld=1")
    OrganizerResponseVO queryOriginalDept(@Param("eventCode") String eventCode, @Param("tableName") String tableName);

    @Select("SELECT ST$DEPT_DEPT_B as stDeptDeptB FROM ${tableName} WHERE BT$EVIF_CODE = ${eventCode} AND ST$DEPT_CODE_B=#{deptCode}")
    String queryNowDept(@Param("eventCode") String eventCode, @Param("deptCode") String deptCode, @Param("tableName") String tableName);

    @Update("update ${tableName} SET isld=0 WHERE BT$EVIF_CODE = ${eventCode} AND isld=1")
    void updateOriginalDept(@Param("eventCode") String eventCode, @Param("tableName") String tableName);

    @Update("update ${tableName} SET isld=1 WHERE BT$EVIF_CODE = ${eventCode} AND ST$DEPT_CODE_B=#{deptCode}")
    void updateNowDept(@Param("eventCode") String eventCode, @Param("deptCode") String deptCode, @Param("tableName") String tableName);

    @Select("SELECT max(code + 0) FROM ${tableName}")
    String getCode(@Param("tableName") String tableName);
}
